package com.my.leetcode;

import java.util.LinkedList;
import java.util.List;
import java.util.Scanner;

public class TestMain {


    public static void main(String[] args) {


        Scanner scanner = new Scanner(System.in);
        while(scanner.hasNext()){
            int m = Integer.parseInt(scanner.nextLine());
            String tmp = scanner.nextLine();
            String [] arr = tmp.split(" ");
            int [] input = new int[arr.length];
            for(int i =0;i < input.length;i++){
                input[i] = Integer.parseInt(arr[i]);
            }
            List<Integer> xiaoyu = new LinkedList<>();
            List<Integer> dayu = new LinkedList<>();
            for(int i = 0;i < input.length;i++){
                if(input[i] <= m){
                    xiaoyu.add(input[i]);
                }else{
                    dayu.add(input[i]);
                }
            }
            StringBuilder sb = new StringBuilder();
            if(!xiaoyu.isEmpty()){
               for(Integer a : xiaoyu){
                   sb.append(a);
                   sb.append(",");
               }
            }
            if(!dayu.isEmpty()){
                for(Integer a : dayu){
                    sb.append(a);
                    sb.append(",");
                }
            }
            System.out.println(sb.toString().substring(0, sb.toString().length() - 1));

        }


    }

    static class ListNode{

        int val;
        ListNode next;

        public ListNode(int val) {
            this.val = val;
        }
    }


    static ListNode partiontion(ListNode head, int m){


        List<Integer> in = new LinkedList<>();
        while(head!= null){
            in.add(head.val);
        }

        List<Integer> xiaoyu = new LinkedList<>();
        List<Integer> dayu = new LinkedList<>();
        for(int i = 0;i < in.size();i++){
            if(in.get(i) <= m){
                xiaoyu.add(in.get(i));
            }else{
                dayu.add(in.get(i));
            }
        }

        ListNode headR =  new ListNode(0);
        ListNode listNode = headR;
        if(!xiaoyu.isEmpty()){
            for(Integer a : xiaoyu){
                listNode.next = new ListNode(a);
                listNode = listNode.next;
            }
        }
        if(!xiaoyu.isEmpty()){
            for(Integer a : dayu){
                listNode.next = new ListNode(a);
                listNode = listNode.next;
            }
        }
        return headR.next;
    }
}
